package com.qf.sp.mybatis.service.impl;

import com.qf.sp.mybatis.dao.UserMapper;
import com.qf.sp.mybatis.entity.User;
import com.qf.sp.mybatis.service.UserService;

import java.util.List;
import java.util.Objects;

/**
 * @author nk
 * @date 2022/4/27 21:12
 */
public class UserServiceImpl implements UserService {
    private UserMapper userMapper;

    public UserMapper getUserMapper() {
        return userMapper;
    }

    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public User login(String name, String password) {
        User user = userMapper.selectByName(name);
        if (Objects.nonNull(user)){
            if (Objects.equals(user.getPassword(),password)){
                return user;
            }
        }
        return null;
    }

    @Override
    public List<User> selectAll() {
        return userMapper.selectAll();
    }
}
